<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="fansId" label="头像" width="80">
        <template slot-scope="{ row }">
          <el-avatar
            :size="50"
            :src="headImg(row.followInfo)"
            style="float: left"
          ></el-avatar>
        </template>
      </el-table-column>
      <el-table-column prop="fansId" label="关注">
        <template slot-scope="{ row }">
          <span>{{ row.followInfo.userName }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="fansId" label="关系" width="80">
        <template slot-scope="{ row }">
          <span>{{ row.relation == 1 ? '关注' : '互粉' }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="关注时间" width="180">
      </el-table-column>
      <el-table-column label="操作" width="200">
        <template slot-scope="{ row }">
          <el-button-group>
            <el-button type="primary" size="mini" @click="handleMessage(row)"
              >发私信</el-button
            >
            <el-popconfirm
              title="确定取消关注吗？"
              @confirm="handleDelete(row)"
            >
              <el-button type="danger" slot="reference" size="mini">
                取消关注
              </el-button>
            </el-popconfirm>
          </el-button-group>
        </template>
      </el-table-column>
      <div slot="empty" class="emptyBg">
        <el-empty :image-size="200"></el-empty>
      </div>
    </el-table>
    <Pagination
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getList"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
  </div>
</template>
<script>
import setInfo from '@/mixins/setInfo'
import Bus from '@/utils/bus.js'
export default {
  mixins: [setInfo],
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
      },
      tableData: [],
      pageObj: {},
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    async getList() {
      let res = await this.$store.dispatch(
        'queryMyFollowBbsFans',
        this.listQuery,
      )
      this.tableData = res.data
      this.pageObj = res
    },
    // 发送私信
    handleMessage(row) {
      Bus.$emit('sendMessage', [row.followInfo.id])
    },
    async handleDelete(row) {
      await this.$store.dispatch('delBbsFans', row)
      this.getList()
    },
  },
}
</script>
<style scoped lang="scss">
</style>